package com.mc.stack;

import java.util.Stack;

public class MinStack {
	private Stack<Integer> data;
	private Stack<Integer> min;
	
	public MinStack(){
		data = new Stack<Integer>();
		min = new Stack<Integer>();
	}
	
	public void push(int element){
		if(data.isEmpty())
			min.push(element);
		else
			min.push(Math.min(element, min.peek()));
		data.push(element);
	}
	
	public void pop(){
		if(data.isEmpty())
			return;
		data.pop();
		min.pop();
	}
	public int min(){
		if(min.isEmpty())
			return -1;
		return min.peek();
	}
}
